package com.migu.contacts.bean;

import java.util.ArrayList;
import java.util.List;

public class DetailBean<T> {
    public int eventType;
    public T data;

    public int id;
    public int status;
    public List<ContactInfoList> contactInfoList;
    public List<Integer> contactIds;

    public void save() {
        if (contactInfoList != null) {
            if (contactIds == null) {
                contactIds = new ArrayList<>();
            }
            for (ContactInfoList infoList : contactInfoList) {
                contactIds.add(infoList.contactId);
            }
        }
    }

    public static class ContactInfoList {
        public int contactId;
        public String realName;
        public String avatar;
        public Integer gender;
        public List<Integer> groupList;

        public ContactInfoList(ContactBean contactBean) {
            contactId = contactBean.id;
            realName = contactBean.realName;
            avatar = contactBean.avatar;
            gender = contactBean.gender;
            groupList = contactBean.groupIdList;
        }
    }

    public String getName() {
        if (contactInfoList != null && contactInfoList.size() > 0) {
            return contactInfoList.get(0).realName;
        }
        return "";
    }

    public String getAvatar() {
        if (contactInfoList != null && contactInfoList.size() > 0) {
            return contactInfoList.get(0).avatar;
        }
        return "";
    }

}
